package edu.hawaii.duedates;

import java.io.Serializable;
import java.util.Comparator;

/**
 * Comparator class used to sort a Collection by BorrowedItem.
 * 
 * @author John Zhou
 * @author John Ly
 */
// FindBugs suggest Serializable should be added causing SuppressWarnings to be added
@SuppressWarnings("serial")
public class LenderComparator implements Comparator<Object>, Serializable {

  /**
   * Override compare so that BorrowedItem can be sorted by library.
   * 
   * @param obj1 The first BorrowItem object to be sorted.
   * @param obj2 The second BorrowItem object to be sorted.
   * @return A negative, zero, or a positive integer corresponding to less than, equal to, or
   * greater than.
   */
  public int compare(Object obj1, Object obj2) {
    BorrowedItem a = (BorrowedItem) obj1;
    BorrowedItem b = (BorrowedItem) obj2;
    return a.getLender().compareTo(b.getLender());
  }

}
